<!--
 * @Author: DeluxePig 250293786@qq.com
 * @Date: 2024-06-05 23:17:14
 * @LastEditors: DeluxePig 250293786@qq.com
 * @LastEditTime: 2024-06-20 00:01:03
 * @FilePath: \easy-talk\src\views\home\index.vue
 * @Description: 主页顶部右侧——我的名片
-->
<template>
  <div class="top-right">
    <div class="top-right-head">
      <div class="title">我的名片</div>
      <div class="template-btn" @click="runTo('/muban-choose')">模板选择</div>
    </div>
    <div class="top-right-body">
      <div v-if="mayCard.template_id && mayCard.template_id !== ''" class="top-right-body-cont">
        <card-shell :businessCard="mayCard.addition_data.businessCard" :cardBackImg="mayCard.addition_data.cardbackImg"
          :templateId="mayCard.template_id" :userInfo="userData" />
      </div>
      <div v-else class="creat-btn" @click="runTo('/muban-choose')">
        + 创建我的AI名片
      </div>
    </div>
  </div>
</template>

<script>
import { cardConfigApi } from '@/api/card'
import { getInfo } from '@/api/user'
import CardShell from '../../components/businessCard/CardShell.vue'
export default {
  name: 'CallCard',
  components: {
    CardShell
  },
  data() {
    return {
      mayCard: {
        users_uniqueid: 'n6mbo00lqb0d0djwg4dx5bnuc3npmgqr',
        enable_status: 1, // 分享可查看状态: 0=关闭,1=开启
        template_id: '1', // 模板id
        template_info: {
          id: 6,
          title: '',
          resource_path: '',
          addition_data: '',
          create_datetime: '2024-05-30 10:22:54',
          update_datetime: '2024-05-31 11:05:02',
          visible_switch: 1
        },
        addition_data: {
          // 额外数据 json-object
          cardbackImg: '', // 背景图
          businessCard: '' // 电子名片
        },
        create_datetime: '2024-04-08 19:02:35',
        update_datetime: '2024-04-08 19:12:46'
      },
      userData: {
        'id': 1,
        'users_uniqueid': 'n6mbo00lqb0d0djwg4dx5bnuc3npmgqr',
        'real_name': '11', // 姓名
        'icon': '', // 头像
        'unit_name': '', // 单位名称
        'unit_logo': '', // 单位logo
        'unit_department': '', // 部门
        'unit_title': '', // 职位
        'unit_job': '', // 任职
        'intro': '', // 简介
        'create_datetime': '2024-04-07 13:49:04',
        'update_datetime': '2024-04-07 13:49:04',
        'phone_visible_switch': 0, // 手机号可见性:0=隐藏,1=可见
        'unit_level': '', // 单位级别
        'real_photo': ''// 真人照片
      },
      honorData: [
        '中国医药教育协会胸外科专委会常务委员'
      ]
    }
  },
  computed: {
  },
  created() {
    this.gertUserData()
    this.getMyCard()
  },
  methods: {
    gertUserData() {
      getInfo().then((res) => {
        this.userData = res.data
      })
    },
    getMyCard() {
      cardConfigApi().then((res) => {
        if (res.data) {
          this.mayCard = res.data
        }
      })
    },
    runTo(url) {
      this.$router.push({ path: url })
    }
  }
}
</script>

<style lang="scss" scoped>
.top-right {
  width: 40%;
  height: 100%;
  background: #fff;
  border-radius: 4px 4px 4px 4px;
  padding: 20px;

  .top-right-head {
    width: 100%;
    height: 24px;
    line-height: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    font-size: 16px;
    color: #1C1F23;

    .template-btn {
      font-weight: 400;
      font-size: 12px;
      color: #04D1B8;
      cursor: pointer;
    }
  }

  .top-right-body {
    width: 100%;
    height: 192px;
    background: linear-gradient(0deg, rgba(223, 249, 238, 0.1) 0%, rgba(199, 246, 230, 0.45) 100%);
    border-radius: 8px;
    border: 1px solid #DBF6F3;
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;

    .creat-btn {
      width: 153px;
      height: 32px;
      line-height: 32px;
      background: #04D1B8;
      border-radius: 20px 20px 20px 20px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      font-size: 14px;
      color: #FFFFFF;
      text-align: center;
      cursor: pointer;
    }

    .top-right-body-cont {
      width: 100%;
      height: 100%;

      .user-box {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        width: 100%;
        height: 80px;
        position: relative;

        .user-img-box {
          width: 80px;
          height: 80px;
          border-radius: 50%;
          overflow: hidden;
          border: 1px solid #eee;
        }

        .user-info-box {
          height: 76px;
          display: flex;
          justify-content: center;
          align-items: flex-start;
          flex-direction: column;
          padding-left: 12px;
          font-size: 14px;
          color: #9E9E9E;

          .info {
            line-height: 26px;
          }

          .name {
            font-weight: 600;
            font-size: 20px;
            color: #1C1F23;
          }

          .hospital {
            font-family: PingFang SC, PingFang SC;
            font-weight: 400;
            font-size: 14px;
            color: #6A6B6C;
            line-height: 16px;
            text-align: left;

            .hospital-level {
              display: inline-block;
              background: rgba(4, 209, 184, 0.1);
              border-radius: 4px 4px 4px 4px;
              padding: 2px 4px;
              margin-right: 8px;
              font-size: 14px;
              color: #08BDA7;

              .iconfont {
                font-size: 12px;
                vertical-align: top;
                margin-right: 2px;
              }
            }
          }

        }
      }

      .honor-box {
        height: calc(100% - 76px);
        width: fit-content;
        margin-top: 6px;

        .honor {
          background: linear-gradient(90deg, #F7F2E4 0%, #FFEFCB 100%);
          border-radius: 4px;
          padding: 3px 16px;
          font-weight: 400;
          font-size: 12px;
          color: #AE6B1A;
          line-height: 14px;
          margin: 2px;

          .iconfont {
            color: rgba(174, 107, 26, 0.2);
          }
        }
      }
    }
  }
}
</style>
